<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- <img width="200px" src="http://127.0.0.1:8081/img" alt="" /> -->
    <img width="200px" id="img" alt="" />
    <script>
      const xhr = new XMLHttpRequest();
      const progressBar = document.getElementById("progressBar");
      xhr.open("GET", "http://127.0.0.1:8081/img");
      // 将二进制封装成对象
      xhr.responseType = "blob";
      // URL.createObjectURL 将二进制对象内容转换为一个临时地址
      xhr.onload = function () {
        const url = URL.createObjectURL(xhr.response);
        img.src = url;
      };
      xhr.send();
    </script>
  </body>
</html>
